<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<title>后台管理</title>
<link rel="stylesheet" type="text/css" href="__STATIC__/admin/layui/css/layui.css" />
<link rel="stylesheet" type="text/css" href="__STATIC__/admin/css/admin.css" />
<script type="text/javascript" charset="utf-8" src="__STATIC__/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="__STATIC__/ueditor/ueditor.all.min.js"> </script>
<script type="text/javascript" charset="utf-8" src="__STATIC__/ueditor/lang/zh-cn/zh-cn.js"></script>
<style>
.layui-form-label{ width:130px;}
.layui-input-block{ margin-left:160px;}
.pic_box{ padding-top:10px;}
</style>
</head>
<body>
<div class="" style=" padding-bottom:30px;">
  <form class="layui-form edit-form" method="post" action="{:url()}" style="width: 90%;padding-top: 30px;">
    {present name="info.id"}
    <input type="hidden" name="id" value="{$info.id|default=''}" />
    {/present}
    <!--<input type="hidden" name="pid" value="{$info.pid|default=input('pid',0)}" />-->
    
    <div class="layui-form-item">
      <label class="layui-form-label">所属栏目：</label>
      <div class="layui-input-block">
        <select name="pid" lay-verify="required">
          <option value="0">顶级栏目</option> 
          {volist name='_tree' id='vo'}
          <option value="{$vo.id}">{$vo.flag} {$vo.title}</option>
          {/volist}
          
        </select>
      </div>
    </div>
    
    <div class="layui-form-item">
      <label class="layui-form-label">栏目名称：</label>
      <div class="layui-input-block">
        <input type="text" name="title" value="{$info.title|default=''}" required lay-verify="required" placeholder="请输入栏目名称" autocomplete="off" class="layui-input">
      </div>
    </div>
    
    <div class="layui-form-item">
      <label class="layui-form-label">栏目英文名：</label>
      <div class="layui-input-block">
        <input type="text" name="en_title" value="{$info.en_title|default=''}" required lay-verify="required" placeholder="请输入栏目英文名" autocomplete="off" class="layui-input">
      </div>
    </div>
    
    <div class="layui-form-item">
      <label class="layui-form-label">Html保存目录：</label>
      <div class="layui-input-block">
        <input type="text" name="dir" value="{$info.dir|default=''}" required lay-verify="required" placeholder="请输入静态文件保存目录" autocomplete="off" class="layui-input">
      </div>
    </div>
    
    <div class="layui-form-item">
      <label class="layui-form-label">模型：</label>
      <div class="layui-input-block">
        <select name="mid" lay-verify="required" lay-filter="mid">
          {volist name='_mx' id='vo'}
          <option value="{$vo.id}">{$vo.title}</option>
          {/volist}
        </select>
      </div>
    </div>
    
    <div class="layui-form-item">
      <label class="layui-form-label">栏目类型：</label>
      <div class="layui-input-block">
        <input type="radio" name="type" value="1" title="封面页" checked>
        <input type="radio" name="type" value="2" title="列表页">
        <input type="radio" name="type" value="3" title="外部链接">
      </div>
    </div>
    
    <div class="layui-form-item">
      <label class="layui-form-label">封面页模板：</label>
      <div class="layui-input-block">
        <input type="text" name="temp_index" value="{$info.temp_index|default='default_index.html'}" required lay-verify="required" placeholder="请输入默认封面页模板" autocomplete="off" class="layui-input">
      </div>
    </div>
    
    <div class="layui-form-item">
      <label class="layui-form-label">列表页模板：</label>
      <div class="layui-input-block">
        <input type="text" name="temp_list" value="{$info.temp_list|default='default_list.html'}" required lay-verify="required" placeholder="请输入默认列表页模板" autocomplete="off" class="layui-input">
      </div>
    </div>
    
    <div class="layui-form-item">
      <label class="layui-form-label">内容页模板：</label>
      <div class="layui-input-block">
        <input type="text" name="temp_view" value="{$info.temp_view|default='default_view.html'}" required lay-verify="required" placeholder="请输入默认内容页模板" autocomplete="off" class="layui-input">
      </div>
    </div>
	
	<div class="layui-form-item">
      <label class="layui-form-label">分页条数：</label>
      <div class="layui-input-block">
        <input type="number" name="page_size" value="{if condition="isset($pinfo)"}{$pinfo.page_size}{elseif condition="isset($info)"/}{$info.page_size}{else/}10{/if}" required lay-verify="required" placeholder="请输入列表页每页显示条数" autocomplete="off" class="layui-input">
      </div>
    </div>
    
    <div class="layui-form-item">
      <label class="layui-form-label">上传图片：</label>
      <div class="layui-input-block">
        <input type="file" name="mfile" lay-ext="jpg|png|gif" class="layui-upload-file">
        {if condition="isset($info['pic']) && !empty($info['pic'])"}
        <div class="pic_box"><img src="{$info.pic}" height="100"></div>
        <input type="hidden" name="pic" class="pic_input" value="{$info.pic}">
        {else/}
        <div class="pic_box"></div>
        <input type="hidden" name="pic" class="pic_input" value="">
        {/if}
      </div>
      
    </div>    
    
    <div class="layui-form-item">
      <label class="layui-form-label">可见性：</label>
      <div class="layui-input-block">
        <input type="radio" name="display" value="1" title="显示" checked>
        <input type="radio" name="display" value="0" title="隐藏">
      </div>
    </div>
    
    <div class="layui-form-item">
      <label class="layui-form-label">栏目关键词：</label>
      <div class="layui-input-block">
        <input type="text" name="keywords" value="{$info.keywords|default=''}" placeholder="请输入栏目关键词" autocomplete="off" class="layui-input">
      </div>
    </div>
    
    <div class="layui-form-item">
      <label class="layui-form-label">栏目描述：</label>
      <div class="layui-input-block">
        <textarea class="layui-textarea" name="description" placeholder="请输入栏目描述" style="height:100px" id="content">{$info.description|default=''}</textarea>
      </div>
    </div>
    
    <div class="layui-form-item layui-form-text">
      <label class="layui-form-label">内容：</label>
      <div class="layui-input-block">
		<script id="editor_content" name="content" type="text/plain" style="height:500px;">
        {$info.content|default=''}
        </script>
        <script type="text/javascript">
            var editor = UE.getEditor('editor_content');
        </script>
      </div>
    </div>
    
    <div class="layui-form-item">
      <div class="layui-input-block">
        <button class="layui-btn layui-btn-normal ajax-post-btn" lay-submit lay-filter="formDemo">提交</button>
        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
      </div>
    </div>
  </form>
</div>
<script src="__STATIC__/js/jquery.min.js" type="text/javascript" charset="utf-8"></script> 
<script src="__STATIC__/admin/layui/layui.js" type="text/javascript" charset="utf-8"></script>
<script src="__STATIC__/js/common.js" type="text/javascript" charset="utf-8"></script> 
<script>
var temp = [];
{volist name='_mx' id='vo'}
temp[{$vo.id}] = {index:"{$vo.temp_index}",list:"{$vo.temp_list}",view:"{$vo.temp_view}"};
{/volist}	
		
layui.use(['form','upload','layedit','laydate'], function() {
	var form = layui.form()
	,laydate = layui.laydate;
	
	form.render();
	
	//监听提交
	form.on('submit(formDemo)', function(data) {
		//layer.msg(JSON.stringify(data.field));
		ajax_post('edit-form',false,'','');
		return false;
	});
	
	form.on('select(mid)', function(data) {
		//console.log(data.value);
		var tmp = temp[data.value];
		$('input[name="temp_index"]').val(tmp.index);
		$('input[name="temp_list"]').val(tmp.list);
		$('input[name="temp_view"]').val(tmp.view);
		return false;
	});
	
	layui.upload({
		url: "{:url('File/upload')}"
		,success: function(res, input){
			if(res.code == 1){
				layer.msg(res.msg);	
				$(input).parents('.layui-input-block').find('.pic_input').val(res.data.src);
				$(input).parents('.layui-input-block').find('.pic_box').html('<img src="'+res.data.src+'" height="100">');
			}else{
				layer.msg(res.msg);		
			}
		}
	});
	
});


setValue("pid", "{$info.pid|default=input('pid',0)}");	
{present name="pinfo.id"}
	setValue("mid", {$pinfo.mid|default=1});
	var mtmp = temp[{$pinfo.mid|default=1}];
	$('input[name="temp_index"]').val(mtmp.index);
	$('input[name="temp_list"]').val(mtmp.list);
	$('input[name="temp_view"]').val(mtmp.view);
{/present}	
{present name="info.id"}
$(function(){
	setValue("mid", {$info.mid|default=1});
	setValue("type", {$info.type|default=1});
	setValue("display", {$info.display|default=1});
});
{/present}
</script>


</body>
</html>